<?php  
/** 
 * Thumbnail Generator for CakePHP that uses phpThumb (http://phpthumb.sourceforge.net/) 
 * 
 * @package default 
 * @author Nate Constant 
 **/  
 
App::uses('Component', 'Controller');
// App::import('Vendor', 'phpExcelReader', array('file' => 'phpExcelReader/Excel/reader.php')); 
App::import('Vendor', 'phpExcelReader', array('file' => 'php-excel-reader/excel_reader2.php')); 

class ExcelReaderComponent extends Component{
     
    var $controller; 
    var $allowed_ext = array('xls');
	var $data = null;     

     
    function startup( &$controller ) { 
      $this->controller = &$controller; 
    } 

	function initialize() {
		// $data = new Spreadsheet_Excel_Reader();
		// $data->setOutputEncoding('CP1251'); // Set output Encoding.
	}
	
	function beforeRender() {
		
	}
	
	function shutdown() {
		
	}
     

    function read($file){
    	try {
			$this->data = new Spreadsheet_Excel_Reader($file);
			// error_reporting(E_ALL ^ E_NOTICE);
			return $this->data;
			
			// echo "<table border='1'>";
			// for ($i = 1; $i <= $data->colcount(); $i++) {
			        // echo "<tr>";
				// for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
					// echo "<td>".$data->sheets[0]['cells'][$i][$j]."</td>";
				// }
				// echo "</tr>";
// 	
			// }
			
    	} catch (Exception $e) {
	    	CakeLog::error($e->getMessage());
			throw $e;
    	}
    }

} 
?>